package com.topisv.tms.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.topisv.tms.entity.PipeStockDetail;
import com.topisv.tms.repository.PipeStockDetailDao;

//Spring Bean的标识.
@Component
//默认将类中的所有public函数纳入事务管理.
@Transactional(readOnly = true)
public class PipeStockDetailService {
	private PipeStockDetailDao pipeStockDetailDao;
	
	@Autowired
	public void setPipeStockDetailDao(PipeStockDetailDao pipeStockDetailDao) {
		this.pipeStockDetailDao = pipeStockDetailDao;
	}

	public List<PipeStockDetail> findByStockCode(String stock_code)
	{
		return pipeStockDetailDao.findByStockCode(stock_code);
	}
	
	public PipeStockDetail getPipeStockDetail(Long id) {
		return pipeStockDetailDao.findOne(id);
	}
	
	@Transactional(readOnly = false)
	public void savePipeStockDetail(PipeStockDetail entity) {
		pipeStockDetailDao.save(entity);
	}
	
	@Transactional(readOnly = false)
	public void deletePipeStockDetail(Long id) {
		pipeStockDetailDao.delete(id);
	}
	
	public List<PipeStockDetail> getAllPipeStockDetail() {
		return (List<PipeStockDetail>) pipeStockDetailDao.findAll();
	}
	
}
